#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
struct ListNode {
    int val;
    ListNode* next;
    ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
    ListNode* swapPairs(ListNode* head) {
        ListNode* p, * p1;
        if (head != NULL && head->next != NULL)
        {
            p = head;
            head = p->next;
            p->next = head->next;
            head->next = p;
        }
        else return head;
        while (p->next != NULL && p->next->next != NULL)
        {
            p1 = p->next->next;
            p->next->next = p1->next;
            p1->next = p->next;
            p->next = p1;
            p = p->next->next;
        }
        return head;
    }
};
int main()
{
    Solution sol;
}